<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<h4
  mat-dialog-title
  i18n
>
  Create a new image pull secret
</h4>
<mat-dialog-content class="kd-dialog-text">
  <ng-container>
    <div i18n>The new secret will be added to the cluster</div>
    <div>
      <form [formGroup]="form">
        <kd-help-section>
          <mat-form-field>
            <input
              matInput
              type="text"
              i18n-placeholder
              placeholder="Secret name"
              name="secretName"
              formControlName="secretName"
              required
            />
            <mat-hint align="end">{{ secretName.value.length }} / {{ secretNameMaxLength }}</mat-hint>
            <mat-error
              *ngIf="secretName.errors?.required"
              i18n
            >
              Name is required.
            </mat-error>
            <mat-error
              *ngIf="secretName.errors?.maxlength"
              i18n
            >
              Name must be up to {{ secretNameMaxLength }} characters long.
            </mat-error>
            <mat-error
              *ngIf="secretName.errors?.pattern"
              i18n
            >
              Name must follow the DNS domain name syntax (e.g. new.image-pull.secret).
            </mat-error>
          </mat-form-field>
          <kd-user-help>
            <span i18n>A secret with the specified name will be added to the cluster in the namespace.</span>
            <a
              href="https://kubernetes.io/docs/concepts/configuration/secret/"
              target="_blank"
              tabindex="-1"
              i18n
            >
              Learn more
              <i class="material-icons">open_in_new</i>
            </a>
          </kd-user-help>
        </kd-help-section>

        <kd-help-section>
          <mat-form-field>
            <input
              matInput
              type="text"
              placeholder="Image pull secret data"
              name="data"
              formControlName="data"
              required
            />
            <mat-error
              *ngIf="data.errors?.required"
              i18n
            >
              Data is required.
            </mat-error>
            <mat-error
              *ngIf="data.errors?.pattern"
              i18n
            >
              Data must be Base64 encoded.
            </mat-error>
          </mat-form-field>
          <kd-user-help>
            <ng-container i18n
              >Specify the data for your secret to hold. The value is the Base64 encoded content of a .dockercfg
              file.</ng-container
            >
            <a
              href="https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod"
              target="_blank"
              tabindex="-1"
              i18n
            >
              Learn more
              <i class="material-icons">open_in_new</i>
            </a>
          </kd-user-help>
        </kd-help-section>
      </form>
    </div>
  </ng-container>
</mat-dialog-content>
<mat-dialog-actions align="end">
  <ng-container>
    <button
      mat-button
      type="submit"
      color="primary"
      (click)="createSecret()"
      i18n
    >
      Create
    </button>
    <button
      mat-button
      (click)="cancel()"
      i18n
    >
      Cancel
    </button>
  </ng-container>
</mat-dialog-actions>
